package org.jactao.registry;

import org.jactao.common.LConstants;

import java.net.InetSocketAddress;

/**
 * Created by fanzetao on 2018/4/8.
 */
public class LRegistryInfo {

    private String serviceName;
    private String version;
    private InetSocketAddress address;
    private Integer weight = 1;

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public InetSocketAddress getAddress() {
        return address;
    }

    public void setAddress(InetSocketAddress address) {
        this.address = address;
    }

    public Integer getWeight() {
        return weight;
    }

    public void setWeight(Integer weight) {
        this.weight = weight;
    }

    public String defaultKey() {
        return serviceName + LConstants.defaultSeparate + version;
    }

    public String defaultValue() {
        return address.getAddress().getHostAddress() + LConstants.defaultSeparate
                + address.getPort()  + LConstants.defaultSeparate +  weight;
    }
}
